﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EpicsJecketClient;
using LibAutoTransmeter;
using System.Collections;
using PSIEpics;
using jtext_EpicsClient;
using System.Threading;

namespace TransMe
{
    class Program
    {

        static private void get1()
        {
            JECLient myclient=new JECLient();
            myclient.AddChannel<ExtTimeType<string>>("WAVE:TF:CONFIG");
            double[] s2 = (double[])(myclient.RecordVAL["WAVE:TF:CONFIG"]);
            int i;
            for (i = 0; i < s2.Length; i++)
            {
                s2[i] = 10;
            }
            myclient.RecordVAL["WAVE:TF:CONFIG"] = s2;
            while (true)
            {
                double[] s;
                try
                {
                     s= (double[])(myclient.RecordVAL["WAVE:TF:CONFIG"]);
                }
                catch
                {

                    continue;
                }
               
                for (i = 0; i < s.Length; i++)
                {
                    Console.Write(s[i].ToString() + ";");
                }
                Console.WriteLine("");
                //Thread.Sleep(500);
            }
        }

        static private void get2()
        {
            JECLient myclient = new JECLient();
            myclient.AddChannel<ExtTimeType<string>>("WAVE:HF:CONFIG");
            double[] s2 = (double[])(myclient.RecordVAL["WAVE:HF:CONFIG"]);
            int i;
            for (i = 0; i < s2.Length; i++)
            {
                s2[i] = 10;
            }
            myclient.RecordVAL["WAVE:HF:CONFIG"] = s2;
            while (true)
            {
                double[] s;
                try
                {
                    s = (double[])(myclient.RecordVAL["WAVE:HF:CONFIG"]);
                }
                catch
                {

                    continue;
                }
               
                for (i = 0; i < s.Length; i++)
                {
                    Console.Write(s[i].ToString() + ";");
                }
                Console.WriteLine(""); //Thread.Sleep(500);
            }
        }

        static private void get3()
        {
            JECLient myclient = new JECLient();

                myclient.AddChannel<ExtTimeType<string>>("WAVE:VF:CONFIG");
                double[] s2 = (double[])(myclient.RecordVAL["WAVE:VF:CONFIG"]);
                int i;
                for (i = 0; i < s2.Length; i++)
                {
                    s2[i] = 10;
                }
                myclient.RecordVAL["WAVE:VF:CONFIG"] = s2;

            while (true)
            {
                double[] s;
                try
                {
                   s = (double[])(myclient.RecordVAL["WAVE:VF:CONFIG"]);
                }
                catch
                {

                    continue;
                }
                
                for (i = 0; i < s.Length; i++)
                {
                    Console.Write(s[i].ToString() + ";");
                }
                Console.WriteLine(""); //Thread.Sleep(500);
            }
        }

        static private void get4()
        {
            JECLient myclient = new JECLient();

                myclient.AddChannel<ExtTimeType<string>>("WAVE:OH:CONFIG");

                double[] s2 = (double[])(myclient.RecordVAL["WAVE:OH:CONFIG"]);
                int i;
                for (i = 0; i < s2.Length; i++)
                {
                    s2[i] = 10;
                }
                myclient.RecordVAL["WAVE:OH:CONFIG"] = s2;
            while (true)
            {
                double[] s;
                try
                {
                     s = (double[])(myclient.RecordVAL["WAVE:OH:CONFIG"]);
                }
                catch
                {

                    continue;
                }
               
                for (i = 0; i < s.Length; i++)
                {
                    Console.Write(s[i].ToString() + ";");
                }
                Console.WriteLine("");// Thread.Sleep(500);
            }
        }

        static private void get5()
        {
            JECLient myclient = new JECLient();
            myclient.AddChannel<ExtTimeType<string>>("WAVE:VES:CONFIGGAS1");
            double[] s2 = (double[])(myclient.RecordVAL["WAVE:VES:CONFIGGAS1"]);
            int i;
            for (i = 0; i < s2.Length; i++)
            {
                s2[i] = 10;
            }
            myclient.RecordVAL["WAVE:VES:CONFIGGAS1"] = s2;
            while (true)
            {
                double[] s;
                try
                {
                     s = (double[])(myclient.RecordVAL["WAVE:VES:CONFIGGAS1"]);
                }
                catch 
                {
                    
                    continue;
                }
               
                for (i = 0; i < s.Length; i++)
                {
                    Console.Write(s[i].ToString() + ";");
                }
                Console.WriteLine("");// Thread.Sleep(500);
            }
        }

        static private void get6()
        {
            JECLient myclient = new JECLient();

                myclient.AddChannel<ExtTimeType<string>>("WAVE:VES:CONFIGGAS2");
                double[] s2 = (double[])(myclient.RecordVAL["WAVE:VES:CONFIGGAS2"]);
                int i;
                for (i = 0; i < s2.Length; i++)
                {
                    s2[i] = 10;
                }
                myclient.RecordVAL["WAVE:VES:CONFIGGAS2"] = s2;

            while (true)
            {
                double[] s;
                try
                {
                     s = (double[])(myclient.RecordVAL["WAVE:VES:CONFIGGAS2"]);
                }
                catch
                {

                    continue;
                }
               
                for (i = 0; i < s.Length; i++)
                {
                    Console.Write(s[i].ToString() + ";");
                }
                Console.WriteLine("");// Thread.Sleep(500);
            }
        }
 

        static void Main(string[] args)
        {
            //EJClient myclient = new EJClient("DUMMY", "cccc", false, 2);
            //myclient.StartClient();

            //TranmeterProp Tprop = new TranmeterProp();
            //Tprop.isByte = false;
            //Tprop.isHost = false;
            //Tprop.mask = "3";
            ////Tprop.myTemplate = "55;01;PV_TEST:CPU0;03;PV_TEST:ARRAY";
            //Tprop.myTemplate = "!!!;PV_TEST:CPU0;@@@;PV_TEST:ARRAY";
            //Tprop.Name = "test";
            //Tprop.PvFlag = "TEST:CPU0";
            //Tprop.Values.Add("TEST:CPU0", "BYTE");
            //Tprop.Values.Add("TEST:ARRAY", "STRING");
            //Tprop.saveMe("d:\\trans.xml");
            //Transmeter Trans = new Transmeter(Tprop);

            //Trans.myEJClient = myclient;

            //Trans.IniTransmeter();
            //Trans.isConsole = true;
            Thread t1 = new Thread(new ThreadStart(get1));
            Thread t2 = new Thread(new ThreadStart(get2));
            Thread t3 = new Thread(new ThreadStart(get3));
            Thread t4 = new Thread(new ThreadStart(get4));
            Thread t5 = new Thread(new ThreadStart(get5));
            Thread t6 = new Thread(new ThreadStart(get6));
            while (true)
            {

                
                
                
                t1.Start();
                t2.Start();
                t3.Start();
                t4.Start();
                t5.Start();
                t6.Start();
                Console.ReadLine();
            }

        }



    }
}
